package com.ditri.distrident.common.constant;

import javafx.util.Pair;

import java.util.regex.Pattern;

/**
 * @author: edxuanlen
 * @date: 2020-08-04 14:12
 * @version: 1.0
 **/
public class CommonConst {

    public static class Time {
        /**
         * 一天的毫秒数
         */
        public static long MILLIS_OF_ONE_DAY = 86400000L;

        /**
         * 一个小时的秒数
         */
        public static long SECONDS_OF_ONE_HOUR = 3600L;


        /**
         * 一分钟的秒数
         */
        public static long SECONDS_OF_ONE_MIN = 60L;
    }

    public static class Phone {

        public static String URL = "http://106.ihuyi.com/webservice/sms.php?method=Submit";

        public static String API_ID = "C35505539";

        public static String API_KEY = "5dfa50560efd7122fced86f9a34cf85a";

        public static int MAX_NUMBER_OF_SENDING_WITH_ONE_HOUR = 5;

        /**
         * SMS 发送提交失败
         */
        public static final String SMS_SEND_SUBMIT_ERROR = "0";

        /**
         * SMS 发送成功
         */
        public static final String SMS_SEND_SUCCESSFUL = "2";

        /**
         * 短信次数不足
         */
        public static final String NO_MORE_SMS_TIMES = "4051";

        /**
         * 手机格式不正确
         */
        public static final String PHONE_FORMAT_ERROR = "406";

        public static String CONTENT_PREFIX = "您的验证码是：";

        public static String CONTENT_SUFFIX = "。请不要把验证码泄露给其他人。";

    }

    public static class Mail {

        /**
         * 发送者邮箱
         */
        public static String SENDER_MAIL_ADDRESS = "distrident@163.com";

        /**
         * 发送者账号名
         */
        public static String SENDER_ACCOUNT = "distrident";

        /**
         * 发送者密码
         */
        public static String SENDER_PASSWORD = "GIGMBRZWESLUSGKS";

        /**
         * 用户的认证方式
         */
        public static Pair<String, String> AUTH = new Pair<>("mail.smtp.auth", "true");

        /**
         * 传输协议
         */
        public static Pair<String, String> PROTOCOL = new Pair<>("mail.transport.protocol", "smtp");

        /**
         * 设置发件人的SMTP服务器地址
         */
        public static Pair<String, String> HOST = new Pair<>("mail.smtp.host", "smtp.163.com");

        /**
         * 一天最大发送数量
         */
        public static Integer MAX_MAIL_SEND_ONE_DAY = 100;

        /**
         * 一个账号一小时内最多发送次数(防止恶意)
         */
        public static Integer MAX_NUMBER_OF_SENDING_WITH_ONE_HOUR = 10;


        public static String CONTENT_PREFIX = "your auth code is:";

        public static String CONTENT_SUFFIX = ". Please use it in one minute!";
    }

    public static class Patterns {

        /**
         * 邮箱正则
         */
        public static String MAIL_REGEXP = "^([0-9A-Za-z\\-_\\.]+)@([0-9a-z]+\\.[a-z]{2,3}(\\.[a-z]{2})?)$";

        /**
         * 邮箱正则预编译
         */
        public static Pattern MAIL_PATTERN = Pattern.compile(MAIL_REGEXP);

        /**
         * 手机正则表达式
         */
        public static String PHONE_REGEXP = "^[1][3,4,5,7,8][0-9]{9}$";

        /**
         * 手机正则预编译
         */
        public static Pattern PHONE_PATTERN = Pattern.compile(PHONE_REGEXP);

        /**
         * url 正则表达式
         */
        public static String URL_REGEXP = "((http|ftp|https):\\/\\/[\\w\\-_]+(\\.[\\w\\-_]+)+([\\w\\-\\.,@?^=%&:/~\\+#]*[\\w\\-\\@?^=%&/~\\+#])?)";


        /**
         * url 正则预编译
         */
        public static Pattern URL_PATTERN = Pattern.compile(URL_REGEXP);
    }

    public static class Redis {


        public static String AUTH_CODE_SEND_TIME_PREFIX = "authCodeTimes_";

        public static String AUTH_CODE_PREFIX = "authCode_";

    }

    public static class User {

        public static String MAIL = "mail";

        public static String PHONE = "phone";
    }

    public static class Blog {
        public static String PREFIX = "001U";
    }

}
